package com.leetcode.demo3Solution.java;

import java.util.HashSet;
import java.util.Set;

public class demo771 {
    public static void main(String[] args) {
        String j="aj";
        String s = "alllldjjdjjaada";
        System.out.println(numJewelsInStones(j,s));
    }



    public static int numJewelsInStones(String J, String S) {
        Set<Character> set=new HashSet<>();
        for(Character m :J.toCharArray()){
            set.add(m);
        }
        int Number=0;
        for (Character s:S.toCharArray()){
            if(set.contains(s)){
                Number++;
            }
        }
        return Number;
       /* Set<Character> Jset = new HashSet();
        for (char j: J.toCharArray())
            Jset.add(j);

        int ans = 0;
        for (char s: S.toCharArray())
            if (Jset.contains(s))
                ans++;
        return ans;*/

    }
}
